package com.fleapx.spring.hook.springhooktest.postprocessor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;

@Component
public class BeanPostProcessorTest implements BeanPostProcessor {

    /**
     *  在Bean(实例化之后)初始化的前后做一些自定义的操作,要后于BeanFactoryPostProcessor实现类执行
     */

    @Override
    public  Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("进入了BeanPostProcessor初始化前");
        System.out.println(beanName+bean);
        return bean;
    }


    @Override
    public  Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("进入了BeanPostProcessor初始化后");
        System.out.println(beanName+bean);
        return bean;
    }
}
